home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / Kubuntu 8.10 / kubuntu-8.10-desktop-i386.iso / casper / filesystem.squashfs / usr / include / linux / ethtool.h < prev    next >
C/C++ Source or Header  |  2008-10-24  |  15KB  |  452 lines

  1. /*
  2.  * ethtool.h: Defines for Linux ethtool.
  3.  *
  4.  * Copyright (C) 1998 David S. Miller (davem@redhat.com)
  5.  * Copyright 2001 Jeff Garzik <jgarzik@pobox.com>
  6.  * Portions Copyright 2001 Sun Microsystems (thockin@sun.com)
  7.  * Portions Copyright 2002 Intel (eli.kupermann@intel.com,
  8.  *                                christopher.leech@intel.com,
  9.  *                                scott.feldman@intel.com)
  10.  */
  11.  
  12. #ifndef _LINUX_ETHTOOL_H
  13. #define _LINUX_ETHTOOL_H
  14.  
  15. #include <linux/types.h>
  16.  
  17. /* This should work for both 32 and 64 bit userland. */
  18. struct ethtool_cmd {
  19.     __u32    cmd;
  20.     __u32    supported;    /* Features this interface supports */
  21.     __u32    advertising;    /* Features this interface advertises */
  22.     __u16    speed;        /* The forced speed, 10Mb, 100Mb, gigabit */
  23.     __u8    duplex;        /* Duplex, half or full */
  24.     __u8    port;        /* Which connector port */
  25.     __u8    phy_address;
  26.     __u8    transceiver;    /* Which transceiver to use */
  27.     __u8    autoneg;    /* Enable or disable autonegotiation */
  28.     __u32    maxtxpkt;    /* Tx pkts before generating tx int */
  29.     __u32    maxrxpkt;    /* Rx pkts before generating rx int */
  30.     __u16    speed_hi;
  31.     __u16    reserved2;
  32.     __u32    reserved[3];
  33. };
  34.  
  35. static inline void ethtool_cmd_speed_set(struct ethtool_cmd *ep,
  36.                         __u32 speed)
  37. {
  38.  
  39.     ep->speed = (__u16)speed;
  40.     ep->speed_hi = (__u16)(speed >> 16);
  41. }
  42.  
  43. static inline __u32 ethtool_cmd_speed(struct ethtool_cmd *ep)
  44. {
  45.     return (ep->speed_hi << 16) | ep->speed;
  46. }
  47.  
  48. #define ETHTOOL_BUSINFO_LEN    32
  49. /* these strings are set to whatever the driver author decides... */
  50. struct ethtool_drvinfo {
  51.     __u32    cmd;
  52.     char    driver[32];    /* driver short name, "tulip", "eepro100" */
  53.     char    version[32];    /* driver version string */
  54.     char    fw_version[32];    /* firmware version string, if applicable */
  55.     char    bus_info[ETHTOOL_BUSINFO_LEN];    /* Bus info for this IF. */
  56.                 /* For PCI devices, use pci_name(pci_dev). */
  57.     char    reserved1[32];
  58.     char    reserved2[12];
  59.     __u32    n_priv_flags;    /* number of flags valid in ETHTOOL_GPFLAGS */
  60.     __u32    n_stats;    /* number of u64's from ETHTOOL_GSTATS */
  61.     __u32    testinfo_len;
  62.     __u32    eedump_len;    /* Size of data from ETHTOOL_GEEPROM (bytes) */
  63.     __u32    regdump_len;    /* Size of data from ETHTOOL_GREGS (bytes) */
  64. };
  65.  
  66. #define SOPASS_MAX    6
  67. /* wake-on-lan settings */
  68. struct ethtool_wolinfo {
  69.     __u32    cmd;
  70.     __u32    supported;
  71.     __u32    wolopts;
  72.     __u8    sopass[SOPASS_MAX]; /* SecureOn(tm) password */
  73. };
  74.  
  75. /* for passing single values */
  76. struct ethtool_value {
  77.     __u32    cmd;
  78.     __u32    data;
  79. };
  80.  
  81. /* for passing big chunks of data */
  82. struct ethtool_regs {
  83.     __u32    cmd;
  84.     __u32    version; /* driver-specific, indicates different chips/revs */
  85.     __u32    len; /* bytes */
  86.     __u8    data[0];
  87. };
  88.  
  89. /* for passing EEPROM chunks */
  90. struct ethtool_eeprom {
  91.     __u32    cmd;
  92.     __u32    magic;
  93.     __u32    offset; /* in bytes */
  94.     __u32    len; /* in bytes */
  95.     __u8    data[0];
  96. };
  97.  
  98. /* for configuring coalescing parameters of chip */
  99. struct ethtool_coalesce {
  100.     __u32    cmd;    /* ETHTOOL_{G,S}COALESCE */
  101.  
  102.     /* How many usecs to delay an RX interrupt after
  103.      * a packet arrives.  If 0, only rx_max_coalesced_frames
  104.      * is used.
  105.      */
  106.     __u32    rx_coalesce_usecs;
  107.  
  108.     /* How many packets to delay an RX interrupt after
  109.      * a packet arrives.  If 0, only rx_coalesce_usecs is
  110.      * used.  It is illegal to set both usecs and max frames
  111.      * to zero as this would cause RX interrupts to never be
  112.      * generated.
  113.      */
  114.     __u32    rx_max_coalesced_frames;
  115.  
  116.     /* Same as above two parameters, except that these values
  117.      * apply while an IRQ is being serviced by the host.  Not
  118.      * all cards support this feature and the values are ignored
  119.      * in that case.
  120.      */
  121.     __u32    rx_coalesce_usecs_irq;
  122.     __u32    rx_max_coalesced_frames_irq;
  123.  
  124.     /* How many usecs to delay a TX interrupt after
  125.      * a packet is sent.  If 0, only tx_max_coalesced_frames
  126.      * is used.
  127.      */
  128.     __u32    tx_coalesce_usecs;
  129.  
  130.     /* How many packets to delay a TX interrupt after
  131.      * a packet is sent.  If 0, only tx_coalesce_usecs is
  132.      * used.  It is illegal to set both usecs and max frames
  133.      * to zero as this would cause TX interrupts to never be
  134.      * generated.
  135.      */
  136.     __u32    tx_max_coalesced_frames;
  137.  
  138.     /* Same as above two parameters, except that these values
  139.      * apply while an IRQ is being serviced by the host.  Not
  140.      * all cards support this feature and the values are ignored
  141.      * in that case.
  142.      */
  143.     __u32    tx_coalesce_usecs_irq;
  144.     __u32    tx_max_coalesced_frames_irq;
  145.  
  146.     /* How many usecs to delay in-memory statistics
  147.      * block updates.  Some drivers do not have an in-memory
  148.      * statistic block, and in such cases this value is ignored.
  149.      * This value must not be zero.
  150.      */
  151.     __u32    stats_block_coalesce_usecs;
  152.  
  153.     /* Adaptive RX/TX coalescing is an algorithm implemented by
  154.      * some drivers to improve latency under low packet rates and
  155.      * improve throughput under high packet rates.  Some drivers
  156.      * only implement one of RX or TX adaptive coalescing.  Anything
  157.      * not implemented by the driver causes these values to be
  158.      * silently ignored.
  159.      */
  160.     __u32    use_adaptive_rx_coalesce;
  161.     __u32    use_adaptive_tx_coalesce;
  162.  
  163.     /* When the packet rate (measured in packets per second)
  164.      * is below pkt_rate_low, the {rx,tx}_*_low parameters are
  165.      * used.
  166.      */
  167.     __u32    pkt_rate_low;
  168.     __u32    rx_coalesce_usecs_low;
  169.     __u32    rx_max_coalesced_frames_low;
  170.     __u32    tx_coalesce_usecs_low;
  171.     __u32    tx_max_coalesced_frames_low;
  172.  
  173.     /* When the packet rate is below pkt_rate_high but above
  174.      * pkt_rate_low (both measured in packets per second) the
  175.      * normal {rx,tx}_* coalescing parameters are used.
  176.      */
  177.  
  178.     /* When the packet rate is (measured in packets per second)
  179.      * is above pkt_rate_high, the {rx,tx}_*_high parameters are
  180.      * used.
  181.      */
  182.     __u32    pkt_rate_high;
  183.     __u32    rx_coalesce_usecs_high;
  184.     __u32    rx_max_coalesced_frames_high;
  185.     __u32    tx_coalesce_usecs_high;
  186.     __u32    tx_max_coalesced_frames_high;
  187.  
  188.     /* How often to do adaptive coalescing packet rate sampling,
  189.      * measured in seconds.  Must not be zero.
  190.      */
  191.     __u32    rate_sample_interval;
  192. };
  193.  
  194. /* for configuring RX/TX ring parameters */
  195. struct ethtool_ringparam {
  196.     __u32    cmd;    /* ETHTOOL_{G,S}RINGPARAM */
  197.  
  198.     /* Read only attributes.  These indicate the maximum number
  199.      * of pending RX/TX ring entries the driver will allow the
  200.      * user to set.
  201.      */
  202.     __u32    rx_max_pending;
  203.     __u32    rx_mini_max_pending;
  204.     __u32    rx_jumbo_max_pending;
  205.     __u32    tx_max_pending;
  206.  
  207.     /* Values changeable by the user.  The valid values are
  208.      * in the range 1 to the "*_max_pending" counterpart above.
  209.      */
  210.     __u32    rx_pending;
  211.     __u32    rx_mini_pending;
  212.     __u32    rx_jumbo_pending;
  213.     __u32    tx_pending;
  214. };
  215.  
  216. /* for configuring link flow control parameters */
  217. struct ethtool_pauseparam {
  218.     __u32    cmd;    /* ETHTOOL_{G,S}PAUSEPARAM */
  219.  
  220.     /* If the link is being auto-negotiated (via ethtool_cmd.autoneg
  221.      * being true) the user may set 'autonet' here non-zero to have the
  222.      * pause parameters be auto-negotiated too.  In such a case, the
  223.      * {rx,tx}_pause values below determine what capabilities are
  224.      * advertised.
  225.      *
  226.      * If 'autoneg' is zero or the link is not being auto-negotiated,
  227.      * then {rx,tx}_pause force the driver to use/not-use pause
  228.      * flow control.
  229.      */
  230.     __u32    autoneg;
  231.     __u32    rx_pause;
  232.     __u32    tx_pause;
  233. };
  234.  
  235. #define ETH_GSTRING_LEN        32
  236. enum ethtool_stringset {
  237.     ETH_SS_TEST        = 0,
  238.     ETH_SS_STATS,
  239.     ETH_SS_PRIV_FLAGS,
  240. };
  241.  
  242. /* for passing string sets for data tagging */
  243. struct ethtool_gstrings {
  244.     __u32    cmd;        /* ETHTOOL_GSTRINGS */
  245.     __u32    string_set;    /* string set id e.c. ETH_SS_TEST, etc*/
  246.     __u32    len;        /* number of strings in the string set */
  247.     __u8    data[0];
  248. };
  249.  
  250. enum ethtool_test_flags {
  251.     ETH_TEST_FL_OFFLINE    = (1 << 0),    /* online / offline */
  252.     ETH_TEST_FL_FAILED    = (1 << 1),    /* test passed / failed */
  253. };
  254.  
  255. /* for requesting NIC test and getting results*/
  256. struct ethtool_test {
  257.     __u32    cmd;        /* ETHTOOL_TEST */
  258.     __u32    flags;        /* ETH_TEST_FL_xxx */
  259.     __u32    reserved;
  260.     __u32    len;        /* result length, in number of u64 elements */
  261.     __u64    data[0];
  262. };
  263.  
  264. /* for dumping NIC-specific statistics */
  265. struct ethtool_stats {
  266.     __u32    cmd;        /* ETHTOOL_GSTATS */
  267.     __u32    n_stats;    /* number of u64's being returned */
  268.     __u64    data[0];
  269. };
  270.  
  271. struct ethtool_perm_addr {
  272.     __u32    cmd;        /* ETHTOOL_GPERMADDR */
  273.     __u32    size;
  274.     __u8    data[0];
  275. };
  276.  
  277. /* boolean flags controlling per-interface behavior characteristics.
  278.  * When reading, the flag indicates whether or not a certain behavior
  279.  * is enabled/present.  When writing, the flag indicates whether
  280.  * or not the driver should turn on (set) or off (clear) a behavior.
  281.  *
  282.  * Some behaviors may read-only (unconditionally absent or present).
  283.  * If such is the case, return EINVAL in the set-flags operation if the
  284.  * flag differs from the read-only value.
  285.  */
  286. enum ethtool_flags {
  287.     ETH_FLAG_LRO        = (1 << 15),    /* LRO is enabled */
  288. };
  289.  
  290. struct ethtool_rxnfc {
  291.     __u32        cmd;
  292.     __u32        flow_type;
  293.     __u64        data;
  294. };
  295.  
  296.  
  297. /* CMDs currently supported */
  298. #define ETHTOOL_GSET        0x00000001 /* Get settings. */
  299. #define ETHTOOL_SSET        0x00000002 /* Set settings. */
  300. #define ETHTOOL_GDRVINFO    0x00000003 /* Get driver info. */
  301. #define ETHTOOL_GREGS        0x00000004 /* Get NIC registers. */
  302. #define ETHTOOL_GWOL        0x00000005 /* Get wake-on-lan options. */
  303. #define ETHTOOL_SWOL        0x00000006 /* Set wake-on-lan options. */
  304. #define ETHTOOL_GMSGLVL        0x00000007 /* Get driver message level */
  305. #define ETHTOOL_SMSGLVL        0x00000008 /* Set driver msg level. */
  306. #define ETHTOOL_NWAY_RST    0x00000009 /* Restart autonegotiation. */
  307. #define ETHTOOL_GLINK        0x0000000a /* Get link status (ethtool_value) */
  308. #define ETHTOOL_GEEPROM        0x0000000b /* Get EEPROM data */
  309. #define ETHTOOL_SEEPROM        0x0000000c /* Set EEPROM data. */
  310. #define ETHTOOL_GCOALESCE    0x0000000e /* Get coalesce config */
  311. #define ETHTOOL_SCOALESCE    0x0000000f /* Set coalesce config. */
  312. #define ETHTOOL_GRINGPARAM    0x00000010 /* Get ring parameters */
  313. #define ETHTOOL_SRINGPARAM    0x00000011 /* Set ring parameters. */
  314. #define ETHTOOL_GPAUSEPARAM    0x00000012 /* Get pause parameters */
  315. #define ETHTOOL_SPAUSEPARAM    0x00000013 /* Set pause parameters. */
  316. #define ETHTOOL_GRXCSUM        0x00000014 /* Get RX hw csum enable (ethtool_value) */
  317. #define ETHTOOL_SRXCSUM        0x00000015 /* Set RX hw csum enable (ethtool_value) */
  318. #define ETHTOOL_GTXCSUM        0x00000016 /* Get TX hw csum enable (ethtool_value) */
  319. #define ETHTOOL_STXCSUM        0x00000017 /* Set TX hw csum enable (ethtool_value) */
  320. #define ETHTOOL_GSG        0x00000018 /* Get scatter-gather enable
  321.                         * (ethtool_value) */
  322. #define ETHTOOL_SSG        0x00000019 /* Set scatter-gather enable
  323.                         * (ethtool_value). */
  324. #define ETHTOOL_TEST        0x0000001a /* execute NIC self-test. */
  325. #define ETHTOOL_GSTRINGS    0x0000001b /* get specified string set */
  326. #define ETHTOOL_PHYS_ID        0x0000001c /* identify the NIC */
  327. #define ETHTOOL_GSTATS        0x0000001d /* get NIC-specific statistics */
  328. #define ETHTOOL_GTSO        0x0000001e /* Get TSO enable (ethtool_value) */
  329. #define ETHTOOL_STSO        0x0000001f /* Set TSO enable (ethtool_value) */
  330. #define ETHTOOL_GPERMADDR    0x00000020 /* Get permanent hardware address */
  331. #define ETHTOOL_GUFO        0x00000021 /* Get UFO enable (ethtool_value) */
  332. #define ETHTOOL_SUFO        0x00000022 /* Set UFO enable (ethtool_value) */
  333. #define ETHTOOL_GGSO        0x00000023 /* Get GSO enable (ethtool_value) */
  334. #define ETHTOOL_SGSO        0x00000024 /* Set GSO enable (ethtool_value) */
  335. #define ETHTOOL_GFLAGS        0x00000025 /* Get flags bitmap(ethtool_value) */
  336. #define ETHTOOL_SFLAGS        0x00000026 /* Set flags bitmap(ethtool_value) */
  337. #define ETHTOOL_GPFLAGS        0x00000027 /* Get driver-private flags bitmap */
  338. #define ETHTOOL_SPFLAGS        0x00000028 /* Set driver-private flags bitmap */
  339.  
  340. #define    ETHTOOL_GRXFH        0x00000029 /* Get RX flow hash configuration */
  341. #define    ETHTOOL_SRXFH        0x0000002a /* Set RX flow hash configuration */
  342.  
  343. /* compatibility with older code */
  344. #define SPARC_ETH_GSET        ETHTOOL_GSET
  345. #define SPARC_ETH_SSET        ETHTOOL_SSET
  346.  
  347. /* Indicates what features are supported by the interface. */
  348. #define SUPPORTED_10baseT_Half        (1 << 0)
  349. #define SUPPORTED_10baseT_Full        (1 << 1)
  350. #define SUPPORTED_100baseT_Half        (1 << 2)
  351. #define SUPPORTED_100baseT_Full        (1 << 3)
  352. #define SUPPORTED_1000baseT_Half    (1 << 4)
  353. #define SUPPORTED_1000baseT_Full    (1 << 5)
  354. #define SUPPORTED_Autoneg        (1 << 6)
  355. #define SUPPORTED_TP            (1 << 7)
  356. #define SUPPORTED_AUI            (1 << 8)
  357. #define SUPPORTED_MII            (1 << 9)
  358. #define SUPPORTED_FIBRE            (1 << 10)
  359. #define SUPPORTED_BNC            (1 << 11)
  360. #define SUPPORTED_10000baseT_Full    (1 << 12)
  361. #define SUPPORTED_Pause            (1 << 13)
  362. #define SUPPORTED_Asym_Pause        (1 << 14)
  363. #define SUPPORTED_2500baseX_Full    (1 << 15)
  364.  
  365. /* Indicates what features are advertised by the interface. */
  366. #define ADVERTISED_10baseT_Half        (1 << 0)
  367. #define ADVERTISED_10baseT_Full        (1 << 1)
  368. #define ADVERTISED_100baseT_Half    (1 << 2)
  369. #define ADVERTISED_100baseT_Full    (1 << 3)
  370. #define ADVERTISED_1000baseT_Half    (1 << 4)
  371. #define ADVERTISED_1000baseT_Full    (1 << 5)
  372. #define ADVERTISED_Autoneg        (1 << 6)
  373. #define ADVERTISED_TP            (1 << 7)
  374. #define ADVERTISED_AUI            (1 << 8)
  375. #define ADVERTISED_MII            (1 << 9)
  376. #define ADVERTISED_FIBRE        (1 << 10)
  377. #define ADVERTISED_BNC            (1 << 11)
  378. #define ADVERTISED_10000baseT_Full    (1 << 12)
  379. #define ADVERTISED_Pause        (1 << 13)
  380. #define ADVERTISED_Asym_Pause        (1 << 14)
  381. #define ADVERTISED_2500baseX_Full    (1 << 15)
  382.  
  383. /* The following are all involved in forcing a particular link
  384.  * mode for the device for setting things.  When getting the
  385.  * devices settings, these indicate the current mode and whether
  386.  * it was foced up into this mode or autonegotiated.
  387.  */
  388.  
  389. /* The forced speed, 10Mb, 100Mb, gigabit, 2.5Gb, 10GbE. */
  390. #define SPEED_10        10
  391. #define SPEED_100        100
  392. #define SPEED_1000        1000
  393. #define SPEED_2500        2500
  394. #define SPEED_10000        10000
  395.  
  396. /* Duplex, half or full. */
  397. #define DUPLEX_HALF        0x00
  398. #define DUPLEX_FULL        0x01
  399.  
  400. /* Which connector port. */
  401. #define PORT_TP            0x00
  402. #define PORT_AUI        0x01
  403. #define PORT_MII        0x02
  404. #define PORT_FIBRE        0x03
  405. #define PORT_BNC        0x04
  406.  
  407. /* Which transceiver to use. */
  408. #define XCVR_INTERNAL        0x00
  409. #define XCVR_EXTERNAL        0x01
  410. #define XCVR_DUMMY1        0x02
  411. #define XCVR_DUMMY2        0x03
  412. #define XCVR_DUMMY3        0x04
  413.  
  414. /* Enable or disable autonegotiation.  If this is set to enable,
  415.  * the forced link modes above are completely ignored.
  416.  */
  417. #define AUTONEG_DISABLE        0x00
  418. #define AUTONEG_ENABLE        0x01
  419.  
  420. /* Wake-On-Lan options. */
  421. #define WAKE_PHY        (1 << 0)
  422. #define WAKE_UCAST        (1 << 1)
  423. #define WAKE_MCAST        (1 << 2)
  424. #define WAKE_BCAST        (1 << 3)
  425. #define WAKE_ARP        (1 << 4)
  426. #define WAKE_MAGIC        (1 << 5)
  427. #define WAKE_MAGICSECURE    (1 << 6) /* only meaningful if WAKE_MAGIC */
  428.  
  429. /* L3-L4 network traffic flow types */
  430. #define    TCP_V4_FLOW    0x01
  431. #define    UDP_V4_FLOW    0x02
  432. #define    SCTP_V4_FLOW    0x03
  433. #define    AH_ESP_V4_FLOW    0x04
  434. #define    TCP_V6_FLOW    0x05
  435. #define    UDP_V6_FLOW    0x06
  436. #define    SCTP_V6_FLOW    0x07
  437. #define    AH_ESP_V6_FLOW    0x08
  438.  
  439. /* L3-L4 network traffic flow hash options */
  440. #define    RXH_DEV_PORT    (1 << 0)
  441. #define    RXH_L2DA    (1 << 1)
  442. #define    RXH_VLAN    (1 << 2)
  443. #define    RXH_L3_PROTO    (1 << 3)
  444. #define    RXH_IP_SRC    (1 << 4)
  445. #define    RXH_IP_DST    (1 << 5)
  446. #define    RXH_L4_B_0_1    (1 << 6) /* src port in case of TCP/UDP/SCTP */
  447. #define    RXH_L4_B_2_3    (1 << 7) /* dst port in case of TCP/UDP/SCTP */
  448. #define    RXH_DISCARD    (1 << 31)
  449.  
  450.  
  451. #endif /* _LINUX_ETHTOOL_H */
  452.